using System;
using System.Diagnostics;
using System.Linq;
using Microsoft.Build.Evaluation;

namespace projectfile
{
    public class ParseDefaultNamespace
    {
        public void In_Process(Project project) {
            Trace.TraceInformation("Get root namespace for project {0}", project.FullPath);
            var defaultNamespace = GetDefaultNamespace(project);
            Trace.TraceInformation("  Found namespace {0}", defaultNamespace);
            Out_Result(defaultNamespace);
        }

        private string GetDefaultNamespace(Project project) {
            return project.Properties
                .Where(x => x.Name == "RootNamespace")
                .Select(x => x.EvaluatedValue)
                .First();
        }

        public Action<string> Out_Result;
    }
}